﻿using System;
using BLL;

public partial class Pages_Dashboard_MasterAccountaspx : System.Web.UI.Page, ICrumbedPage
{
    public int MaccountID
    {
        get
        {
            int temp;
            int.TryParse(Request["ID"], out temp);
            return temp;
        }
    }
    protected BO.User User;
    private void Authenicate()
    {
        if (Authentication.IsCurrentUserAuthenticated())
            User = Authentication.GetCurrentUser();

        if (User == null)
            Response.Redirect("/default.aspx");
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        Authenicate();
        if (!IsPostBack)
            LoadData();
    }

    private void LoadData()
    {
        var mAccount = BLL.MasterAccounts.GetByID(MaccountID);
        if (mAccount == null || User.ProfileID != mAccount.ProfileID)
            Response.Redirect("/default.aspx");

        ltrName.Text = mAccount.Name;
        TailName = mAccount.Name;

        repAccounts.DataSource = Logic.BusinessLogic.Stats.GetAccountsOverview(MaccountID);
        repAccounts.DataBind();
    }

    #region ICrumbedPage Members

    public int Level
    {
        get { return 2; }
    }

    public string TailName { get; set; }

    #endregion
}